<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\SoftDeletes;
/**
 * @property int $id 主键
 * @property int $mid 机构ID
 * @property int $car_id 关联车辆
 * @property int $driver_id 关联司机
 * @property string $accident_time 事故日期
 * @property string $place 发生地点
 * @property string $accident_description 事故说明
 * @property string $handling_situation 处理情况
 * @property string $results 处理结果
 * @property string $loss_adjuster 定损人
 * @property string $repair_location 修理地点
 * @property string $responsibility 责任认定
 * @property string $handler 经手人
 * @property string $compensation_amount 赔偿金额
 * @property int $status 状态
 * @property string $remark 备注
 * @property int $created_user 创建人
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 更新时间
 * @property string $deleted_at 软删除字段
 */
class VehicleAccident extends BaseModel
{
    use SoftDeletes;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'vehicle_accidents';

    protected $hidden = ['deleted_at'];
    
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id', 'mid', 'car_id', 'driver_id', 'accident_time', 'place', 'accident_description', 'handling_situation', 'results', 'loss_adjuster', 'repair_location', 'responsibility', 'handler', 'compensation_amount', 'status', 'remark', 'created_user', 'created_at', 'updated_at', 'deleted_at'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'mid' => 'integer', 'car_id' => 'integer', 'driver_id' => 'integer', 'responsibility' => 'integer','status' => 'integer', 'created_user' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
    /**
     * [createuser 创建者]
     * @return [type] [description]
     */
    public function createuser()
    {
        return $this->hasOne(User::class, 'id', 'created_user');
    }
    /**
     * [vehicle 关联车辆]
     * @return [type] [description]
     */
    public function vehicle()
    {
        return $this->hasOne(Vehicle::class, 'id', 'car_id');
    }
    /**
     * [driver 关联司机]
     * @return [type] [description]
     */
    public function driver()
    {
        return $this->hasOne(User::class, 'id', 'driver_id');
    }
    /**
     * [org 机构]
     * @return [type] [description]
     */
    public function org()
    {
        return $this->hasOne(Institution::class, 'id', 'mid');
    }
}